﻿using MQTTnet;
using MQTTnet.Client.Publishing;
using MQTTnet.Formatter;
using MQTTnet.Protocol;
using System;
using System.Security.Authentication;
using System.Threading.Tasks;

namespace MqttLib
{
    /// <summary>
    /// mqtt 基类
    /// </summary>
    public interface IMqttNetBase : IDisposable
    {
        /// <summary>
        /// 静态工厂
        /// </summary>
        private static readonly MqttFactory _mqttFactory = new MqttFactory();

        /// <summary>
        /// 创建工厂
        /// </summary>
        static MqttFactory Factory { get { return _mqttFactory; } }

        string Username { get; }
        string Pwd { get; }
        string IP { get; }
        int Port { get; }
        uint MaxPacketSize { get; }
        /// <summary>
        /// mqtt协议版本
        /// </summary>
        MqttProtocolVersion MqttVersion { get; }
        /// <summary>
        /// ssl协议版本
        /// </summary>
        SslProtocols SslVersion { get; }
        /// <summary>
        /// 会话超时
        /// </summary>
        TimeSpan CommunicationTimeout { get; }

        //void Init();

        Task<bool> StartAsync();

        Task StopAsync();

        Task<MqttClientPublishResult> Publish(MqttApplicationMessage msg);

    }
}